//
//  LoginViewController.m
//  Project_IOS
//
//  Created by Jeff on 2022/1/11.
//

#import "BindVC.h"
#import "LoginNumberView.h"
//#import "YNTNetworkManager.h"
#import "UserCancelVC.h"
#import <Masonry/Masonry.h>
#import "Color.h"
@interface BindVC ()
@property (nonatomic, strong) UIView *centerView;

@property (nonatomic, strong) LoginNumberView *phoneView;

@end

@implementation BindVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.titleStr = @"绑定账号";
    
//    [self.view addSubview:self.centerView];
//    [self.centerView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(343), 500)));
//            make.top.mas_equalTo(137));
//            make.centerX.mas_equalTo(0);
//    }];
    
    self.phoneView = [[LoginNumberView alloc] initPhone:true];
    [self.phoneView.textField addTarget:self action:@selector(textfieldContentChange:) forControlEvents:UIControlEventEditingChanged];
    
    [self.buttonView.button addTarget:self action:@selector(loginBtnOnClick) forControlEvents:UIControlEventTouchUpInside];
    self.buttonView.avable = false;
    self.buttonView.btnStr = @"下一步";
    
    [self.contentView addSubview:self.phoneView];
    [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(110);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(311, 52));
    }];
    
    
    
    [self.contentView addSubview:self.buttonView];
    [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(311, 48));
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(self.phoneView.mas_bottom).offset(45);
    }];
    
   
}

- (void)loginBtnOnClick {
    
    [self.phoneView.textField resignFirstResponder];
    if (self.phoneView.textField.text.length != 11) {
//        [MBProgressHUD showMessage:@"请检查输入项！"];
        return;
    }
    UserCancelVC *vc = [UserCancelVC new];
    vc.isBind = YES;
    vc.mobile = self.phoneView.textField.text;
    [self.navigationController pushViewController:vc animated:YES];

}


- (UIView *)centerView {
    if (!_centerView) {
        _centerView = [[UIView alloc] init];
        _centerView.backgroundColor = [Color colorWithHexString:@"#FFFFFF"];
        _centerView.layer.cornerRadius = 15;
        _centerView.layer.masksToBounds = true;
    }
    return _centerView;
}


- (void)textfieldContentChange:(UITextField *)field {
    if (self.phoneView.textField.text.length == 11) {
        self.buttonView.avable = true;
    }else{
        self.buttonView.avable = false;
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
